﻿using Granite.Collections;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;

namespace Granite.Commons.Tests.Collections
{

    [TestClass()]
    public class CollectionUtilitiesTests
    {

        [TestMethod()]
		public void CollectionUtilities_AddRange_Test1()
        {
            try
            {
                List<string> target = new List<string>();
                List<string> list = null;
                CollectionUtilities.AddRange(target, list);

                Assert.Fail("Expected an ArgumentNullException");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("list", ex.ParamName, "Incorrect parameter name");
            }
        }

        [TestMethod()]
		public void CollectionUtilities_AddRange_Test2()
        {
            try
            {
                List<string> target = null;
                List<string> list = null;
                CollectionUtilities.AddRange(target, list);

                Assert.Fail("Expected a ArgumentNullException");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("target", ex.ParamName, "Incorrect parameter name");
            }
        }

        [TestMethod()]
		public void CollectionUtilities_AddRange_Test3()
        {
            List<string> target = new List<string>();
            List<string> list = new List<string>();
            target.Add("AAA");
            list.Add("BBB");
            list.Add("CCC");

            CollectionUtilities.AddRange(target, list);
            Assert.AreEqual("AAA", target[0]);
            Assert.AreEqual("BBB", target[1]);
            Assert.AreEqual("CCC", target[2]);
        }

        [TestMethod()]
		public void CollectionUtilities_AddRange_Test4()
        {
            List<string> target = new List<string>();
            List<string> list = new List<string>();
            target.Add("AAA");
            target.Add("BBB");
            target.Add("CCC");

            CollectionUtilities.AddRange(target, list);
            Assert.AreEqual("AAA", target[0]);
            Assert.AreEqual("BBB", target[1]);
            Assert.AreEqual("CCC", target[2]);
        }

        [TestMethod()]
		public void CollectionUtilities_AddRange_Test5()
        {
            List<string> target = new List<string>();
            List<string> list = new List<string>();
            list.Add("AAA");
            list.Add("BBB");
            list.Add("CCC");

            CollectionUtilities.AddRange(target, list);
            Assert.AreEqual("AAA", target[0]);
            Assert.AreEqual("BBB", target[1]);
            Assert.AreEqual("CCC", target[2]);
        }
        
        [TestMethod()]
		public void CollectionUtilities_AddRange_Test6()
        {
            List<string> target = new List<string>();

            CollectionUtilities.AddRange(target, "AAA", "BBB", "CCC");
            Assert.AreEqual("AAA", target[0]);
            Assert.AreEqual("BBB", target[1]);
            Assert.AreEqual("CCC", target[2]);
        }

        [TestMethod()]
		public void CollectionUtilities_AddRange_Test7()
        {
            try
            {
                List<string> target = new List<string>();
                string[] list = null;
                CollectionUtilities.AddRange(target, list);

                Assert.Fail("Expected an ArgumentNullException");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("list", ex.ParamName, "Incorrect parameter name");
            }
        }

        [TestMethod()]
		public void CollectionUtilities_AddRange_Test8()
        {
            try
            {
                List<string> target = null;
                string[] list = null;
                CollectionUtilities.AddRange(target, list);

                Assert.Fail("Expected an ArgumentNullException");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("target", ex.ParamName, "Incorrect parameter name");
            }
        }


        [TestMethod()]
		public void CollectionUtilities_InsertRange_Test1()
        {
            try
            {
                List<string> target = new List<string>();
                List<string> list = null;
                CollectionUtilities.InsertRange(target, 0, list);

                Assert.Fail("Expected an ArgumentNullException");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("list", ex.ParamName, "Incorrect parameter name");
            }
        }

        [TestMethod()]
		public void CollectionUtilities_InsertRange_Test2()
        {
            try
            {
                List<string> target = null;
                List<string> list = null;
                CollectionUtilities.InsertRange(target, 0, list);

                Assert.Fail("Expected a ArgumentNullException");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("target", ex.ParamName, "Incorrect parameter name");
            }
        }

        [TestMethod()]
		public void CollectionUtilities_InsertRange_Test3()
        {
            List<string> target = new List<string>();
            List<string> list = new List<string>();
            target.Add("AAA");
            list.Add("BBB");
            list.Add("CCC");

            CollectionUtilities.InsertRange(target, 0, list);
            Assert.AreEqual("BBB", target[0]);
            Assert.AreEqual("CCC", target[1]);
            Assert.AreEqual("AAA", target[2]);
        }

        [TestMethod()]
		public void CollectionUtilities_InsertRange_Test4()
        {
            List<string> target = new List<string>();
            List<string> list = new List<string>();
            target.Add("AAA");
            target.Add("BBB");
            target.Add("CCC");

            CollectionUtilities.InsertRange(target, 0, list);
            Assert.AreEqual("AAA", target[0]);
            Assert.AreEqual("BBB", target[1]);
            Assert.AreEqual("CCC", target[2]);
        }

        [TestMethod()]
		public void CollectionUtilities_InsertRange_Test5()
        {
            List<string> target = new List<string>();
            List<string> list = new List<string>();
            list.Add("AAA");
            list.Add("BBB");
            list.Add("CCC");

            CollectionUtilities.InsertRange(target, 0, list);
            Assert.AreEqual("AAA", target[0]);
            Assert.AreEqual("BBB", target[1]);
            Assert.AreEqual("CCC", target[2]);
        }


        [TestMethod()]
        public void CollectionUtilities_InsertRange_Test6()
        {
            List<string> target = new List<string>() { "A", "B", "C" };
            List<string> list = new List<string>();
            try
            {
                CollectionUtilities.InsertRange(target, -1, list);

                Assert.Fail("Expected an ArgumentOutOfRangeException");
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Assert.AreEqual("startingIndex", ex.ParamName, "Incorrect parameter name");
            }
        }

        [TestMethod()]
        public void CollectionUtilities_InsertRange_Test7()
        {
            List<string> target = new List<string>() { "A", "B", "C" };
            List<string> list = new List<string>();
            try
            {
                CollectionUtilities.InsertRange(target, 4, list);

                Assert.Fail("Expected an ArgumentOutOfRangeException");
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Assert.AreEqual("startingIndex", ex.ParamName, "Incorrect parameter name");
            }
        }

        [TestMethod()]
		public void CollectionUtilities_RemoveRange_Test1()
        {
            try
            {
                List<string> list = null;
                CollectionUtilities.RemoveRange(list, 0, 1);

                Assert.Fail("Expected an ArgumentNullException");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("list", ex.ParamName, "Incorrect parameter name");
            }
        }

        [TestMethod()]
		public void CollectionUtilities_RemoveRange_Test2()
        {
            List<string> list = new List<string>();
            list.Add("AAA");
            list.Add("BBB");
            list.Add("CCC");
            CollectionUtilities.RemoveRange(list, 0, 1);

            Assert.AreEqual("BBB", list[0]);
            Assert.AreEqual("CCC", list[1]);

        }


        [TestMethod()]
		public void CollectionUtilities_RemoveRange_Test3()
        {
            List<string> list = new List<string>();
            list.Add("AAA");
            list.Add("BBB");
            list.Add("CCC");
            CollectionUtilities.RemoveRange(list, 0, 2);

            Assert.AreEqual("CCC", list[0]);

        }


        [TestMethod()]
		public void CollectionUtilities_RemoveRange_Test4()
        {
            List<string> list = new List<string>();
            list.Add("AAA");
            list.Add("BBB");
            list.Add("CCC");
            CollectionUtilities.RemoveRange(list, 1, 2);

            Assert.AreEqual("AAA", list[0]);

        }

        [TestMethod()]
        public void CollectionUtilities_RemoveRange_Test5()
        {
            List<string> target = new List<string>() {"A", "B", "C" };
            try
            {
                CollectionUtilities.RemoveRange(target, 3, 1);

                Assert.Fail("Expected an ArgumentOutOfRangeException");
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Assert.AreEqual("startingIndex", ex.ParamName, "Incorrect parameter name");
            }
        }

        [TestMethod()]
        public void CollectionUtilities_RemoveRange_Test6()
        {
            List<string> target = new List<string>() { "A", "B", "C" };
            try
            {
                CollectionUtilities.RemoveRange(target, -1, 1);

                Assert.Fail("Expected an ArgumentOutOfRangeException");
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Assert.AreEqual("startingIndex", ex.ParamName, "Incorrect parameter name");
            }
        }


        [TestMethod()]
		public void CollectionUtilities_SelectRange_Test1()
        {
            try
            {
                List<string> list = null;
                CollectionUtilities.SelectRange(list, 0, 1);

                Assert.Fail("Expected an ArgumentNullException");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("list", ex.ParamName, "Incorrect parameter name");
            }
        }

        [TestMethod()]
		public void CollectionUtilities_SelectRange_Test2()
        {
            List<string> list = new List<string>();
            list.Add("AAA");
            list.Add("BBB");
            list.Add("CCC");
            var result = CollectionUtilities.SelectRange(list, 0, 1);

            Assert.AreEqual("AAA", result[0]);

        }

        [TestMethod()]
		public void CollectionUtilities_SelectRange_Test3()
        {
            List<string> list = new List<string>();
            list.Add("AAA");
            list.Add("BBB");
            list.Add("CCC");
            var result = CollectionUtilities.SelectRange(list, 0, 2);

            Assert.AreEqual("AAA", result[0]);
            Assert.AreEqual("BBB", result[1]);

        }

        [TestMethod()]
		public void CollectionUtilities_SelectRange_Test4()
        {
            List<string> list = new List<string>();
            list.Add("AAA");
            list.Add("BBB");
            list.Add("CCC");
            var result = CollectionUtilities.SelectRange(list, 1, 2);

            Assert.AreEqual("BBB", result[0]);
            Assert.AreEqual("CCC", result[1]);
        }

        [TestMethod()]
		public void CollectionUtilities_SelectRange_Test5()
        {
            try
            {
                List<string> list = new List<string>();
                list.Add("AAA");
                list.Add("BBB");
                list.Add("CCC");
                var result = CollectionUtilities.SelectRange(list, 3, 1);
                Assert.Fail("Expected an ArgumentOutOfRangeException");
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Assert.AreEqual(ex.ParamName, "startingIndex", "Incorrect parameter name");
            }

        }

        [TestMethod()]
		public void CollectionUtilities_SelectRange_Test6()
        {
            try
            {
                List<string> list = new List<string>();
                list.Add("AAA");
                list.Add("BBB");
                list.Add("CCC");
                var result = CollectionUtilities.SelectRange(list, 0, 4);
                Assert.Fail("Expected an ArgumentOutOfRangeException");
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Assert.AreEqual(ex.ParamName, "count", "Incorrect parameter name");
            }

        }

        [TestMethod()]
		public void CollectionUtilities_SelectRange_Test7()
        {
            try
            {
                List<string> list = new List<string>();
                list.Add("AAA");
                list.Add("BBB");
                list.Add("CCC");
                var result = CollectionUtilities.SelectRange(list, -1, 1);
                Assert.Fail("Expected an ArgumentOutOfRangeException");
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Assert.AreEqual(ex.ParamName, "startingIndex", "Incorrect parameter name");
            }

        }


		//[TestMethod()]
		//public void CollectionUtilities_GetCursor_Test1()
		//{
		//	var list = new List<int>();
		//	var cursor = list.GetCursor();
		//	Assert.IsNotNull(cursor);
		//}

		//[TestMethod()]
		//public void CollectionUtilities_GetCursor_Test2()
		//{
		//	List<int> list = null;
		//	try
		//	{
		//		var cursor = list.GetCursor();
		//		Assert.Fail("Expected an ArgumentNullException");
		//	}
		//	catch (ArgumentNullException ex)
		//	{
		//		Assert.AreEqual(ex.ParamName, "list", "Incorrect parameter name");
		//	}
		//}






    }
}
